package com.ruoyi.web.controller.myOrder;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.domain.SysUserOrder;
import com.ruoyi.system.service.SysUserOrderService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/myOrder")
public class MyOrderController extends BaseController {
    @Resource
    private SysUserOrderService sysUserOrderService;

    /**
     * @Deprecated 查询我的订单分页接口
     * @param sysUserOrder 订单实体类对象
     * @return 返回查询到的数据
     */
    @GetMapping("/queryPageList")
    public TableDataInfo queryPageList(SysUserOrder sysUserOrder) {
        LoginUser loginUser = getLoginUser();
        startPage();
        sysUserOrder.setUserId(loginUser.getUserId());
        List<SysUserOrder> list = sysUserOrderService.selectMyOrderPageList(sysUserOrder);
        return getDataTable(list);
    }

    /**
     * @Deprecated 派送订单给投标人
     * @param sysUserOrder 订单实体类对象
     * @return 返回成功或失败的数据
     */
    @PostMapping("/addOrder")
    public AjaxResult addOrder(@RequestBody SysUserOrder sysUserOrder) {
        LoginUser loginUser = getLoginUser();
        return sysUserOrderService.addOrder(sysUserOrder,loginUser);
    }


    /**
     * @Deprecated 订单通过或拒绝按钮
     * @param sysUserOrder 订单实体类对象
     * @return 返回成功或失败的数据
     */
    @PostMapping("/orderPassOrRefuse")
    public AjaxResult orderPassOrRefuse(@RequestBody SysUserOrder sysUserOrder) {
        LoginUser loginUser = getLoginUser();
        return sysUserOrderService.orderPassOrRefuse(sysUserOrder,loginUser);
    }


}
